var t = getApp(),
    s = t.requirejs("core");
t.requirejs("jquery"), t.requirejs("foxui");


Page({
    data: {
        winHeight: "", //窗口高度
        currentTab: 0, //预设当前项的值
        scrollLeft: 0, //tab标题的滚动条位置
        showtab: "do",
        success: "",
        page: 1,
        list: {},
    },
    // 点击标题切换当前页时改变样式
    swichNav: function (e) {
        var that = this
        var cur = e.target.dataset.current;
        that.setData({
            currentTab: cur
        })
        s.post("groups/team", {
            success: cur,
            page: that.data.page,
            zczlstatus: 0
        }, ((e) => {
            console.log(e,'1111');
            e.list.forEach(item => {
                item.num=100/item.groupnum*item.goodsnum
                item.num=item.num.toFixed(0)
            });
            console.log(e.list,'e.list');
            that.setData({
                list: e.list
            })
        }))
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function () {
        var that = this;
        //  高度自适应
        wx.getSystemInfo({
            success: function (res) {
                var clientHeight = res.windowHeight,
                    clientWidth = res.windowWidth,
                    rpxR = 750 / clientWidth;
                var calc = clientHeight * rpxR - 180;
                that.setData({
                    winHeight: calc
                });
            }
        });
        t.getCache("isIpx") ? this.setData({
            isIpx: !0,
            iphonexnavbar: "fui-iphonex-navbar"
        }) : this.setData({
            isIpx: !1,
            iphonexnavbar: ""
        }), this.get_list();

    },
    get_list: function (t) {
        var e = this;
        s.get("groups/team", {
            success: e.data.success,
            page: e.data.page,
            zczlstatus: 0
        }, function (t) {
            console.log(t, 1111);
            0 == t.error && (e.setData({
                list: t.list
            }), wx.stopPullDownRefresh());
        });
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {
        wx.navigateBack({
            delta: 1,
        });
    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    // onShareAppMessage: function () {

    // }
})